package com.aboo.infrastructure.base.exception;

import com.aboo.infrastructure.base.domain.dto.Result;
import com.aboo.infrastructure.base.enums.ErrEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName GlobalExceptionHandler
 * @Description
 * @Author louan
 * @Date 2021/3/23
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    public Result<Void> exceptionHandler(Exception e) {
        log.error("抛异常了", e);
        return Result.error();
    }

    @ExceptionHandler(value = NullPointerException.class)
    public Result<Void> nullPointerException(NullPointerException e) {
        log.error("抛异常了", e);
        return Result.error(ErrEnum.ERR_000002);
    }

}
